<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>jQuery异步请求</title>
    <style>
        .title {
            color: #1296db;
            font-weight: bold;
            font-size: 24px;
            padding: 10px;
        }

        #msg {
            height: 30px;
            font-size: 24px;
            width: 600px;
            border: 2px solid #1296db;
            border-radius: 3px;
        }

        .btn {
            color: #fff;
            font-weight: bold;
            font-size: 24px;
            background: #1296db;
            width: 200px;
            text-align: center;
            padding: 10px 30px;
        }
    </style>
</head>

<body>
    <div class="title">将你想说的话放到下面输入框中，点击播放按钮聆听一下</div>
    <input id="msg" type="text" placeholder="请输入你想说的话" />
    <div class="btn">播放</div>
    <audio></audio>
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script>
        $(".btn").click(function () {
            $.get("http://doctor.codecore.cn/test",
                { content: $("#msg").val()},
                function (res) {
                    $("audio").attr("src",res.src)
                    $("audio")[0].play()
                }
            )
            
        })
    </script>
</body>

</html>